<?php

namespace app\common\model;

use think\Model;
use think\model\relation\BelongsTo;

/**
 * em_order_board
 * @property integer $id (主键)
 * @property integer $company_id 本站点
 * @property integer $next_company_id 下一站点
 * @property string $driver_name 司机姓名
 * @property string $driver_mobile 司机电话
 * @property string $license 大车牌照
 * @property string $freight_price 本段运费
 * @property string $fuel_price 加油费
 * @property string $handling_price 装卸费
 * @property string $forklift_price 叉车费
 * @property string $other_price 其他费用
 * @property string $other_remark 其他费用备注
 * @property string $orders 车列表
 * @property string $create_time 创建时间
 * @property string $update_time 编辑时间
 * @property integer $status 状态
 */
class OrderBoard extends Model
{
    /**
     * The connection name for the model.
     *
     * @var string|null
     */
    protected $connection = 'mysql';
    
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'em_order_board';
    
    /**
     * The primary key associated with the table.
     *
     * @var string
     */
    protected $pk = 'id';
    
    public function getOrdersAttr($value)
    {
        return json_decode($value, true);
    }
    
    
    public function nextDept(): BelongsTo
    {
        return $this->belongsTo('Dept', 'next_dept_id')->bind(['next_dept_name' => 'name']);
    }
    
    public function items()
    {
        return $this->hasMany('OrderBoardItem', 'board_id', 'id');
    }
}
